package com.akkainaction.tool.io.streams.source;

import akka.NotUsed;
import akka.actor.ActorSystem;
import akka.stream.ActorMaterializer;
import akka.stream.Materializer;
import akka.stream.javadsl.Source;

public class TestRepeatSource {

    public static void main(String[] args) {
        ActorSystem system = ActorSystem.create("sys");
        //materializer主要用来给流分配Actor并驱动其执行
        Materializer materializer = ActorMaterializer.create(system);
        // 重复的生成元素
        Source<String, NotUsed> s3 = Source.repeat("Hello");
        // 取出前5个
        s3.limit(5).runForeach(System.out::println, materializer);
    }
}
